
//  do-file: YM CJK FTA.do      
//  author:  Youngmi Choi 

//explaining variables
//iig1: sum of each industry's value
//iig2: iig1*significance(trade/gdp)
//tci: average of extci and imtci
//iig3: iig2+tci(with standardization)



//#1: Check for missing & drop as necessary
misschk fta politya freea popa opena gdpa gdpgrowtha gdppa gdppgrowtha polcon affinity tci iig2 tradegdp, gen(m)

tab mnumber, m //*this tabs the new var for # of missing by case
keep if mnumber==0 //*this keeps only those with no missing data on variables of interest


//#2: panel & tsset
egen group=group(country ccode), label
tsset group year

//#3: ladder test
ladder dis //identity
ladder pop // log
ladder open // log
ladder gdp // log
ladder gdpgrowth //doesn't matter
ladder gdpp //log
ladder gdppgrowth // identity is the best
ladder ppp // log
ladder affinity // identity
ladder tciexport //identity
ladder tciimport // identity
ladder trade //identity
ladder tradegdp

//#4: creating log variables
gen logpop = log(pop)
gen logopen = log(open)
gen loggdp = log(gdp)
gen loggdpp = log(gdpp)
gen logppp = log(ppp)

gen logpopa = log(popa)
gen logopena = log(opena)
gen loggdpa = log(gdpa)
gen loggdppa = log(gdppa)
gen logpppa = log(pppa)
gen logdis= log(dis)
gen logtradegdp = log(tradegdp)

//#6: Descriptive statistics
sum fta freea polcona affinity logdis logpopa logopena loggdpa loggdppa trade iig3 


//#7: binary test for 0, 1
drop if fta>1
tab fta

probit fta iig3 politya polcona affinity logtradegdp dis logpopa logopena loggdppa gdpgrowtha 
//#8: binary test for 1, 2
drop if fta<1
drop if fta>2
replace fta=0 if fta==1
replace fta=1 if fta==2

probit fta iig3 politya polcona affinity logtradegdp dis logpopa logopena loggdppa gdpgrowtha

//#9: binary test for 2, 3

drop if fta<2
drop if fta>3
replace fta=0 if fta==2
replace fta=1 if fta==3

probit fta iig3 politya polcona affinity logtradegdp dis logpopa logopena loggdppa gdpgrowtha 

//#10: binary test for for 3, 4
drop if fta<3

replace fta=0 if fta==3
replace fta=1 if fta==4

probit fta iig3 politya polcona affinity logtradegdp dis logpopa logopena loggdppa gdpgrowtha 


//#11: robustness check: mprobit
mprobit fta iig3 politya polcona affinity logtradegdp dis logpopa logopena loggdppa gdpgrowtha 
mprobit fta iig3 politya polcona affinity logtradegdp dis logpopa logopena loggdppa gdpgrowtha, base(1)
mprobit fta iig3 politya polcona affinity logtradegdp dis logpopa logopena loggdppa gdpgrowtha, base(2) 
mprobit fta iig3 politya polcona affinity logtradegdp dis logpopa logopena loggdppa gdpgrowtha, base(3)

//#12: IIA test
ologit fta freea polcona affinity dis logpopa logopena loggdppa gdpgrowtha trade iig3 time
brant, detail

**the test says paralle regression assumption is violating which menas I can't use the ordered logit


